package me.yushuai.wukong.base.entity;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import me.yushuai.wukong.common.domain.NamedPersistable;
import org.hibernate.Hibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Objects;

/**
 * @author zhoushuai@189.cn
 * @since 2023-05-24
 */
@Getter
@Setter
@ToString
@Entity
@Table(name = "BAS_CONF_VAR")
public class ConfigVariable extends NamedPersistable<Long> {

    /**
     * 所属配置Id
     */
    @Column(name = "CONF_ID")
    private Long confId;

    /**
     * 变量名称
     */
    @Column(name = "VAR_NAME", nullable = false, length = 40)
    private String name;

    /**
     * 描述
     */
    @Column(name = "VAR_NOTES", length = 200)
    private String notes;

    /**
     * 变量值
     */
    @Column(name = "VAR_VALUE", length = 200)
    private String value;


    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        ConfigVariable that = (ConfigVariable) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
